<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>addStyles</title>
</head>

<body>
    <div id="test">测试文本</div>
    <script>
        const addStyles = (el, styles) => Object.assign(el.style, styles);
        addStyles(document.getElementById('test'), {
            background: 'red',
            color: '#ffff00',
            fontSize: '3rem'
        });
    </script>
</body>

</html>